#!/bin/bash

set -e

rm -rf bin
rm -rf tmp
mkdir tmp
cleanup_exit() {
  echo "Test failed" ${2}
  exit ${1}
}

echo "Build should fail"
../../build.py build ... > tmp/output 2>&1 && cleanup_exit 1 "build :a #1 succeded"

# the target which triggered the problem should be in the output
cat tmp/output
cat tmp/output | grep '//:a' || cleanup_exit 1 'bad output.'

rm -rf bin
rm -rf tmp

echo 'Test passed'
